import http from "@/api";
import { AddCommdity, AddTeaItemParam, CommodityListType, EditCommdity, EnableCommdityParams, GetTeaItemQuery, GetTeaListParam, TeaItemListType } from "@Tea/model";

const commodityManageHttp = {
  getTeaList: (params: GetTeaListParam) => http<CommodityListType[]>({
    method: "post",
    url: "/admin/commodityManage/pageList",
    params
  }),
  addCommdity: (params: AddCommdity) => http({
    method: "post",
    url: "/admin/commodityManage/addCommdity",
    params
  }),
  editCommdity: (params: EditCommdity) => http({
    method: "post",
    url: "/admin/commodityManage/editCommdity",
    params
  }),
  enableCommdity: (params: EnableCommdityParams) => http({
    method: "put",
    url: "/admin/commodityManage/enableCommdity",
    params
  }),
  /****以上是商品的增删改查 ****/
  // 添加更多图片
  getTeaItems: (params: GetTeaItemQuery) => http<TeaItemListType[]>({
    method: "get",
    url: "/admin/commodityManage/getTeaItems",
    params
  }),
  addTeaItem: (params: AddTeaItemParam) => http<number>({
    method: "post",
    url: "/admin/commodityManage/addTeaItem",
    params
  }),
  delTeaItem: (itemId: TeaItemListType['itemId']) => http({
    method: "delete",
    url: `/admin/commodityManage/delTeaItem?itemId=${itemId}`,
  })
}

export default commodityManageHttp